<?php

namespace app\admin\validate\knowledge;

use ShidianUtil\Thinkphp\Validate\BaseValidate;

/**
 * Class Knowledge
 * @package app\knowledge\validate
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037623
 */
class Knowledge extends BaseValidate
{

    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'id' => 'isId',
        'userId' => 'integer|egt:0|max:11',
        'checkStatus' => 'integer|egt:0|max:1',
        'categoryId' => 'integer|egt:0|max:11',
        'smallPic' => 'scalar|max:200',
        'title' => 'scalar|max:200',
        'content' => 'scalar',
        'isHot' => 'integer|egt:0|max:1',
        'keywords' => 'scalar|max:255',
        'readNum' => 'integer|egt:0|max:11',
        'likeNum' => 'integer|egt:0|max:11',
        'updated' => 'integer|egt:0|max:11',
        'created' => 'integer|egt:0|max:11',
        'page' => 'integer|egt:0|max:11',
        'page_size' => 'integer|egt:0|max:11',
    ];

    protected $field = [
        'id' => 'id',
        'userId' => 'userId',
        'checkStatus' => 'checkStatus',
        'categoryId' => '法塘分类',
        'smallPic' => '图片',
        'title' => '法塘标题',
        'content' => '法塘内容',
        'isHot' => '是否是热点知识',
        'keywords' => 'keywords',
        'readNum' => 'readNum',
        'likeNum' => 'likeNum',
        'updated' => 'updated',
        'created' => 'created',
        'page' => '分页页数',
        'page_size' => '分页大小',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'id.require' => '缺少:attribute',
        'id.isId' => '请设置正确的:attribute',
        'userId.require' => '请输入:attribute',
        'userId.integer' => ':attribute应该是整数',
        'userId.egt' => ':attribute应该大于等于:rule',
        'userId.max' => ':attribute长度不能超过:rule位',
        'checkStatus.require' => '请输入:attribute',
        'checkStatus.integer' => ':attribute应该是整数',
        'checkStatus.egt' => ':attribute应该大于等于:rule',
        'checkStatus.max' => ':attribute长度不能超过:rule位',
        'categoryId.require' => '请输入:attribute',
        'categoryId.integer' => ':attribute应该是整数',
        'categoryId.egt' => ':attribute应该大于等于:rule',
        'categoryId.max' => ':attribute长度不能超过:rule位',
        'smallPic.require' => '请输入:attribute',
        'smallPic.scalar' => ':attribute应该是字符串',
        'smallPic.max' => ':attribute长度不能超过:rule位',
        'title.require' => '请输入:attribute',
        'title.scalar' => ':attribute应该是字符串',
        'title.max' => ':attribute长度不能超过:rule位',
        'content.require' => '请输入:attribute',
        'content.scalar' => ':attribute应该是字符串',
        'isHot.require' => '请输入:attribute',
        'isHot.integer' => ':attribute应该是整数',
        'isHot.egt' => ':attribute应该大于等于:rule',
        'isHot.max' => ':attribute长度不能超过:rule位',
        'keywords.require' => '请输入:attribute',
        'keywords.scalar' => ':attribute应该是字符串',
        'keywords.max' => ':attribute长度不能超过:rule位',
        'readNum.require' => '请输入:attribute',
        'readNum.integer' => ':attribute应该是整数',
        'readNum.egt' => ':attribute应该大于等于:rule',
        'readNum.max' => ':attribute长度不能超过:rule位',
        'likeNum.require' => '请输入:attribute',
        'likeNum.integer' => ':attribute应该是整数',
        'likeNum.egt' => ':attribute应该大于等于:rule',
        'likeNum.max' => ':attribute长度不能超过:rule位',
        'updated.require' => '请输入:attribute',
        'updated.integer' => ':attribute应该是整数',
        'updated.egt' => ':attribute应该大于等于:rule',
        'updated.max' => ':attribute长度不能超过:rule位',
        'created.require' => '请输入:attribute',
        'created.integer' => ':attribute应该是整数',
        'created.egt' => ':attribute应该大于等于:rule',
        'created.max' => ':attribute长度不能超过:rule位',
        'page.require' => '请输入:attribute',
        'page.integer' => ':attribute应该是整数',
        'page.egt' => ':attribute应该大于等于:rule',
        'page.max' => ':attribute长度不能超过:rule位',
        'page_size.require' => '请输入:attribute',
        'page_size.integer' => ':attribute应该是整数',
        'page_size.egt' => ':attribute应该大于等于:rule',
        'page_size.max' => ':attribute长度不能超过:rule位',
    ];

    protected $scene = [
        'delete' => ['id' => 'require'],
        'index' => ['page', 'page_size'],
        'read' => ['id' => 'require'],
        'save' => ['checkStatus', 'categoryId' => 'require', 'smallPic' => 'require', 'title' => 'require', 'content' => 'require', 'isHot', 'keywords', 'readNum', 'likeNum', 'updated', 'created'],
    ];

}
